package com.sky.mapper;

import com.sky.dto.GoodsSalesDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;


@Mapper
public interface ReportMapper {
    @Select("select sum(amount) from orders where status = 5 and order_time between #{begin} and #{end}")
    Double sumByMap(Map map);
    @Select("select count(id) from orders where order_time between #{begin} and #{end}")
    Integer dayCount(Map map);
    @Select( "select count(id) from orders where status = 5 and order_time between #{begin} and #{end}")
    Integer dayValidCount(Map map);
    @Select("select count(id) from user where create_time between #{begin} and #{end}")
    Integer dayNewUserCount(Map map);
    @Select("select order_detail.name,sum(order_detail.number) as number from order_detail,orders where orders.id = order_detail.order_id and orders.status = 5 and orders.order_time between #{begin} and #{end} " +
            "group by order_detail.name " +
            "order by number desc limit 0,10")
    List<GoodsSalesDTO> sclectTop10ByMap(Map map);
    @Select("select count(id) from user where create_time < #{begin}")
    Integer dayTotalUserCount(Map map);
}
